package com.ngc.mall.bo;

import com.ngc.mall.domain.SkuDomain;
import com.ngc.mall.dto.SkuInfoDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;

/**
 *
 * 订单保存的sku信息格式
 * @author: chenxiaolin
 * @date 2023/8/26 11:05
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderSku {
    private Long id;
    private BigDecimal totalPrice;

    private BigDecimal singlePrice;

    private Integer count;

    private String img;

    private String title;

    private Long spuId;

    private List<String> specs;

    public OrderSku(SkuDomain sku, SkuInfoDTO skuInfoDTO) {
        this.totalPrice =sku.getActualPrice().multiply(new BigDecimal(skuInfoDTO.getCount()));
        this.singlePrice =sku.getActualPrice();
        this.count =skuInfoDTO.getCount();
        this.img=sku.getImg();
        this.title=sku.getTitle();
        this.specs=sku.getSpecValueList();
        this.id=sku.getId();
        this.spuId=sku.getSpuId();
    }
}
